﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DB_NH.DB_Map.SimpleFlow
{
    using NHibernate;
    using NHibernate.Mapping.ByCode;
    using NHibernate.Mapping.ByCode.Conformist;

    using DB_NH.DB_Model.SimpleFlow;

    public class MapForsfToDo : EntityMapping<sfToDo>
    {
        public MapForsfToDo()
        {
            Property(x => x.Title, map =>
            {
                map.Length(500);
            }); 
            
            ManyToOne(x => x.Record, map =>
            {
                map.Column("RecordID");
            });

            ManyToOne(x => x.Step, map =>
            {
                map.Column("StepID");
            });

            Bag(x => x.ToDoMails, map =>
            {
                map.Key(keyMapper => keyMapper.Column("RecordID"));
            }, rel => rel.OneToMany());

            Bag(x => x.ToDoMails, map =>
            {
                map.Key(keyMapper => keyMapper.Column("ToDoID"));
            }, rel => rel.OneToMany());

            Bag(x => x.ToDoUsers, map =>
            {
                map.Key(keyMapper => keyMapper.Column("ToDoID"));
            }, rel => rel.OneToMany());
        }
    }
}
